import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { XiaomanModule } from './examples/xiaoman/xiaoman.module';
import { UserModule } from './examples/user/user.module';
import { ConfigModule } from './common/config/config.module'; // 自定义ConfigModule
import { UploadModule } from './examples/upload/upload.module';
import { RedisModule } from './common/cache/redis.module';
import { LogsModule } from './common/logger/logs.module';
import { CacheManager } from './common/cache/cacheManager.module';
import { MailModule } from './common/mail/mail.module';
// import { ConfigModule } from '@nestjs/config';
import { CatsModule } from './examples/cat/cats.module';
import { ConfigService } from '@nestjs/config';
import { UserRepository } from './examples/user/user.repository';
import { User } from './examples/user/entities/user.entity';
import { DatabaseModule } from './database/database.module';
import { AuthModule } from './auth/auth.module';
import { APP_GUARD } from '@nestjs/core';
import { JwtGuard } from './common/gurads/jwt.guard';
import { RoleModule } from './examples/role/role.module';


const connections = new Map()
@Module({
  imports: [
    // ConfigModule.forRoot({ path: '/learn-nestjs' }), // 自定义ConfigModule使用
    ConfigModule,
    UploadModule,
    LogsModule,
    RedisModule,
    CacheManager,
    MailModule,
    DatabaseModule, // 连接数据库
    // CatsModule,
    UserModule, 
    AuthModule, 
    RoleModule
  ],
  controllers: [AppController],
  // 告诉nestjs,去DI中初始化这个类
  // 如果不在这里注册，就会是import -> module -> provides + exports -> AppService
  // provides -> AppService
  // controllers -> AppService
  providers: [
    AppService,
    UserRepository,
    {
      provide: APP_GUARD,
      useClass: JwtGuard
    }
  ],
  // 告诉nestjs，要导出这些类
  exports: [
    AppService, 
    UserRepository,
  ]
})
export class AppModule { }
